//
//  TestProblem148.swift
//  LeetCodeTests
//
//  Created by 武侠 on 2023/6/26.
//  Copyright © 2023 zhulongiMac02. All rights reserved.
//

import XCTest
@testable import LeetCode

final class TestProblem148: XCTestCase {

    var problem = Problem148()
    
    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    // MARK: - 排序
    func testProblem148_Case1() throws {
        let root = ListNode(4)
        root.next = ListNode(2)
        root.next?.next = ListNode(1)
        root.next?.next?.next = ListNode(3)
        XCTAssertEqual(printNode(problem.sortList(root)), "1 -> 2 -> 3 -> 4 -> ")
    }
    
    func testProblem148_Case2() throws {
        let root = ListNode(-1)
        root.next = ListNode(5)
        root.next?.next = ListNode(3)
        root.next?.next?.next = ListNode(4)
        root.next?.next?.next?.next = ListNode(0)
        XCTAssertEqual(printNode(problem.sortList(root)), "-1 -> 0 -> 3 -> 4 -> 5 -> ")
    }
    
    func testProblem148_Case3() throws {
        let root = ListNode(-1)
        XCTAssertEqual(printNode(problem.sortList(root)), "-1 -> ")
    }
    
    func testProblem148_Case4() throws {
        XCTAssertEqual(printNode(problem.sortList(nil)), "")
    }
}
